package com.lds.sign_sdk.desensitizer;

import com.lds.sign_sdk.util.DesensitizeUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.lang.invoke.MethodHandles;

/**
 * @Date 2022/7/29
 * @Time 15:56
 * @Author liudongs
 * @E-mail liudongs@aliyun.com
 * @Version 1.0.0
 * @Description
 **/
public class DefaultDesensitizer implements IDesensitizer{
    private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());

    public DefaultDesensitizer() {
    }

    @Override
    public String execute(String val1, String val2) {
        if (val1 != null && val1.length() != 0 && val2 != null && val2.length() != 0) {
            String sensitiveInfo = DesensitizeUtil.encryptSensitiveInfo(val1, val2);
            logger.debug("脱敏原值：" + val1);
            logger.debug("脱敏后值：" + sensitiveInfo);
            return sensitiveInfo;
        } else {
            return "";
        }
    }
}
